package com.web.common.aop;

import com.web.common.BaseResult;
import com.web.common.enums.BaseStatus;
import com.web.config.ConsumerRunner;
import com.web.pendingList.entity.PendingList;
import com.web.pendingList.service.PendingListService;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.List;

/**
 * @author wenzhuo
 * @create 2024-04-04 2024/4/4
 */
@Aspect
@Component
public class AnnotationAop {

    private final static Logger logger = LoggerFactory.getLogger(AnnotationAop.class);

    @Pointcut(value = "@annotation(approveCheck)", argNames = "approveCheck")
    public void pointcut(ApproveCheck approveCheck) {
    }


    //TODO 未明确该切面需要处理什么业务
    @Before("@annotation(com.web.common.aop.ApproveCheck)") // 切点表达式
    public void checkData(JoinPoint joinPoint) {
        //获取传入该方法的参数信息
        List<Object> args = Arrays.asList(joinPoint.getArgs());
        PendingList pendingList = (PendingList) args.get(0);
        String userName = (String) args.get(1);
        logger.info("userName: "+userName);

    }

}


